Ext.define('ES.controller.upload.UploadController',{
	extend:'Ext.app.Controller',
	 views: [
        'uploadComp.UploadComp'
    ],
     refs: [
        {
        	ref:'uploadcompRef',
        	selector:'uploadcomp'
        }
    ],
    requires:['ES.view.uploadComp.UploadComp','ES.model.upload.UploadModel','ES.store.upload.UploadStore'],
    init:function(){
    	this.control({
    		'uploadcomp':{
    			show:this.onUploadRendered
    		}
    	});
    },
    onUploadRendered:function(uComp){
    	uComp.down('combo[name=category]').on('change',this.onCategorySelect)
    	uComp.down('button[action=save]').on('click',function(){
    		alert('upload script called');	
    	})
    },
    onCategorySelect:function(catCombo, newValue, oldValue){
    	catCombo.getStore().each(function(result){
    		if(result.get('name') == newValue)
    		{
    			Ext.ComponentQuery.query('combo[name=subCategory]')[0].getStore().loadData(result.get('subCategory'));
    		}
    	})
    }
});